package org.example.struct.array;

/**
 * @author liyishan
 * @date 2023/12/6 09:28
 * @apiNote
 */

public class Test00409LongestPalindrome {

    public static int longestPalindrome(String s) {
        int[] count = new int[128];
        int length = s.length();
        for(int i = 0; i < length; i++){
            char c = s.charAt(i);
            count[c]++;
        }
        int ans = 0;
        for(int v:count){
            ans += v/2 * 2;
            if(ans % 2 == 0 && v % 2 == 1) {
                ans++;
            }
        }
        return ans;
    }
}
